<script type="text/javascript">
	function doSearchPaymentRecord(value) {
		
	}
	
	//表格查询  
	function reloadPaymentRecord() {
		var params = paymentRecord_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		paymentRecord_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		paymentRecord_list.datagrid('unselectAll');
		paymentRecord_list.datagrid('uncheckAll');
	}


	function addPaymentRecord() {
		createFromWindow("新增信息", "paymentRecord.do?editPaymentRecord", "paymentRecord.do?savePaymentRecord",
				function(data) {
					reloadPaymentRecord();
				});
	}
	
	function deletePaymentRecord() {
		var rows = paymentRecord_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('paymentRecord.do?deletePaymentRecordItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadPaymentRecord();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editPaymentRecord() {
		var rows = paymentRecord_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "paymentRecord.do?editPaymentRecord&paymentRecordId=" + rows[0].id,
					"paymentRecord.do?savePaymentRecord", function(data) {
						reloadPaymentRecord();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookPaymentRecord(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = paymentRecord_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "paymentRecord.do?editPaymentRecord&paymentRecordId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditPaymentRecord(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = paymentRecord_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "paymentRecord.do?editPaymentRecord&paymentRecordId=" + id,
					"paymentRecord.do?savePaymentRecord", function(data) {
						reloadPaymentRecord();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendPaymentRecord() {
		printLog('发送');
	}
	
	function operationsDeletePaymentRecord(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('paymentRecord.do?deletePaymentRecordItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadPaymentRecord(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearPaymentRecordSearch() {
		setGridSearchParams('paymentRecord_list','paymentRecordSearchForm',true,reloadPaymentRecord);
	}
	
	//根据条件查询
	function paymentRecordSearch() {
		setGridSearchParams('paymentRecord_list','paymentRecordSearchForm',false,reloadPaymentRecord);
	}
	
	function onDblClickPaymentRecordRow(rowIndex, rowData) {
		createFromWindow("编辑信息", "paymentRecord.do?editPaymentRecord&paymentRecordId=" + rowData.id,
					"paymentRecord.do?savePaymentRecord", function(data) {
						reloadPaymentRecord();
					},true);
	}
	
	function confirmRecPaymentRecord() {
		var rows = paymentRecord_list.datagrid('getChecked');
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			printLog(rows[0]);
			createFromWindow("收款信息", "paymentRecord.do?confirmRecPaymentPage&paymentRecordId=" + rows[0].id,
					"paymentRecord.do?confirmPaymentRecord", function(data) {
						reloadPaymentRecord();
					},true,600,300);
			
// 			var payType = '';
// 			if(rows[0].payType=='XJ') {
// 				payType='现金';
// 			}else if(rows[0].payType=='ZFB') {
// 				payType='支付宝';
// 			}else if(rows[0].payType=='WX') {
// 				payType='微信';
// 			}else if(rows[0].payType=='YL') {
// 				payType='银联';
// 			}
// 			var desc = '<div>是否确认该笔收款已经到账？<br/>客户名称 : '+rows[0].customerName+'<br/>金额 : ￥'+rows[0].amount+'<br/>&nbsp;&nbsp;&nbsp;支付方式 : '+payType+'</div>';
// 			$.messager.confirm('确认',desc , function(r) {
// 				if (r) {
// 					$.post('paymentRecord.do?confirmPaymentRecord', {
// 						id : rows[0].id
// 					}, function(result) {
// 						if (result.success) {
// 							reloadPaymentRecord(); 
// 						}
// 						showMsg(result.msg);
// 					}, 'json');
// 				}
// 			});
		} else {
			showMsg('请选择操作记录.');
		}
	}
</script>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="paymentRecord_list" toolbar="#paymentRecordlist_search" idField="id"
			 url="paymentRecord.do?loadList&status=1" rownumbers="true" onDblClickRow="onDblClickPaymentRecordRow(rowIndex, rowData)"
			 item="com.xdtech.ad.vo.PaymentRecordItem"/>
		
		<div id="paymentRecordlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="paymentRecordSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="paymentRecordSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearPaymentRecordSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="paymentRecord_toolbar" style="height: auto">
<!-- 				<@eu.linkbutton showName="新增" shiro="ad:paymentRecord:add" iconCls="icon-add" onclick="addPaymentRecord()"/> -->
<!-- 				<@eu.linkbutton showName="删除" shiro="ad:paymentRecord:delete" iconCls="icon-remove" onclick="deletePaymentRecord()"/> -->
<!-- 				<@eu.linkbutton showName="编辑" shiro="ad:paymentRecord:edit" iconCls="icon-edit" onclick="editPaymentRecord()"/> -->
				<@eu.linkbutton showName="确认收款" shiro="ad:paymentRecord:confirmRec" iconCls="icon-edit" onclick="confirmRecPaymentRecord()"/>
				<@eu.linkbutton showName="刷新" shiro="ad:paymentRecord:refresh" iconCls="icon-reload" onclick="reloadPaymentRecord()"/>
				
			</div>
		</div>
	</div>
</div>